{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1.0 导入包"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import tensorflow as tf\n",
    "import matplotlib.pyplot as plt\n",
    "from tf_utils import load_dataset"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1.1 Visualizing the dataset"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "train_X shape:  (12, 1)\ntrain_y shape:  (12, 1)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "Text(0, 0.5, 'Water flowing out of the dam (y)')"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAfIAAAFACAYAAABHk/6uAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4wLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvqOYd8AAAIABJREFUeJzt3XmUZGV9//H3BwRRIWmRUQmLg7gFCUFsiCe4gUskcT+ayDGGqJFoNLaDGlHz0zGbEpdx/BkXEozEoEhwVzQiQoBEkB5AliCiiGjkJ2N0FKMiMN/fH/d2qGl6ud3TVdXV/X6dU6fqPnWXb92Zrm8993nu86SqkCRJo2mHYQcgSZIWz0QuSdIIM5FLkjTCTOSSJI0wE7kkSSPMRC5J0ggzkUuSNMJM5JIkjTATuSRJI+xOww6giz322KPWrl077DAkSRqITZs2fb+q1nRZdyQS+dq1a5mcnBx2GJIkDUSSb3Vd10vrkiSNMBO5JEkjzEQuSdIIM5FLkjTCTOSSJI0wE7kkSSPMRC5J0mJVzb08ACZySZIWY/16WLfu9uRd1SyvXz/QMEzkkiQtVBV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Q6h+YHx4Q7rz+Yq4H49yyfQzD3/OuDvpwqT3APYXFW3LCB+aahM5NI82jnKn0Zz6fkbSa4E1jPH/MFVtYUmQVxO04Hqog6Hehewpr2k/irgMpqpazcDfwh8qH3vAuAOndcW6Tzge+0UrufR1FKnEvkpwHiSSZra+VcBquq/aS5rX5HkzW378geBLyW5HDidbRP9nOb6fO2Mc58Gjmqf51x/Dp8BHg3Q/gA7FDihqk4BfpFkambBI2hmHZRGhrOfSctEkh2Bnarq50n2p7kV6gFtzVnbIcldaOZ/Pnyu6WiTfBR4dVVdPbDgpO1kG7m0fNwVOLvtZBbgRSbxpVFVP0vyepoOe9fPtE6SnYGPm8Q1aqyRS5I0wmwjlyRphJnIJUkaYSZySZJGmIlckqQRZiKXJGmE/X8vscs47TSGJQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 576x360 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "train_X, train_y, Xval, yval, Xtest, ytest = load_dataset()\n",
    "print('train_X shape: ', train_X.shape)\n",
    "print('train_y shape: ', train_y.shape)\n",
    "plt.figure(figsize=(8, 5))\n",
    "plt.scatter(train_X, train_y, c='r',marker='x')\n",
    "plt.xlabel('Change in water level (x)')\n",
    "plt.ylabel('Water flowing out of the dam (y)')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1.2 Regularized linear regression cost function"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Tensor(\"Add_4:0\", shape=(?, 1), dtype=float32)\n"
     ]
    }
   ],
   "source": [
    "X = tf.placeholder(\"float\")\n",
    "Y = tf.placeholder(\"float\")\n",
    "\n",
    "tf.set_random_seed(1)  # so that your \"random\" numbers match ours\n",
    "\n",
    "# Set model weights\n",
    "W = tf.Variable(tf.random_normal((1,1)), name=\"weight\")\n",
    "b = tf.Variable(3.0, name=\"bias\")\n",
    "# Construct a linear model\n",
    "pred = tf.add(tf.matmul(X, W), b)  # (12, 1)  (1, 1)  (12, 1)\n",
    "print(pred)\n",
    "# Y = WX + b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [],
   "source": [
    "def model(train_X, train_y, learning_rate=0.001, lambd=0.1,\n",
    "          num_epochs=1500, print_cost=True):\n",
    "    costs = []\n",
    "    m, n= train_X.shape\n",
    "    print(m, n)\n",
    "    cost = tf.reduce_sum(tf.square(pred - train_y))/ (2 * m)\n",
    "    \n",
    "    optimizer = tf.train.GradientDescentOptimizer(learning_rate).minimize(cost)\n",
    "    # Initialize the variables (i.e. assign their default value)\n",
    "    init = tf.global_variables_initializer()\n",
    "    \n",
    "    with tf.Session() as sess:\n",
    "        sess.run(init)\n",
    "        # J = sess.run(cost, feed_dict={X: train_X, Y: train_y})\n",
    "        # print(J)\n",
    "        for epoch in range(num_epochs):\n",
    "            _, epoch_cost = sess.run([optimizer, cost], feed_dict={X:train_X, Y:train_y})\n",
    "            # Print the cost every epoch\n",
    "            if lambd != 0.0:\n",
    "                re_cost = sess.run(tf.contrib.layers.l2_regularizer(lambd)(W))\n",
    "                epoch_cost = epoch_cost + re_cost\n",
    "            if epoch % 100 == 0 and print_cost == True:\n",
    "                print(\"Cost after epoch %i: %f\" % (epoch, epoch_cost))\n",
    "            if epoch % 5 == 0:\n",
    "                costs.append(epoch_cost)\n",
    "        return costs, W.eval(), b.eval()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "12 1\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cost after epoch 0: 602.205078\nCost after epoch 100: 62.953468\nCost after epoch 200: 55.797771\nCost after epoch 300: 49.903900\nCost after epoch 400: 45.049328"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\nCost after epoch 500: 41.050816\nCost after epoch 600: 37.757362\nCost after epoch 700: 35.044689\nCost after epoch 800: 32.810360"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\nCost after epoch 900: 30.970028\nCost after epoch 1000: 29.454220\nCost after epoch 1100: 28.205694\nCost after epoch 1200: 27.177322"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\nCost after epoch 1300: 26.330311\nCost after epoch 1400: 25.632656\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYgAAAEKCAYAAAAIO8L1AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4wLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvqOYd8AAAHu5JREFUeJzt3Xu0HWd93vHvs/e5STq660iVJTmyjSiYFoyjumZBWA4mFDsEOQlOnIRay/FaKtSkQNqVGpJS0jZZJhQI7kpNXQyWs7g5BmrjuBhH4JCW2vgYfBfGwhhbyJaOrPvt3Pavf8y7z9k62pejy2jvo3k+a+01M++8e/Y73vJ+zsw7844iAjMzs6lK7W6AmZl1JgeEmZnV5YAwM7O6HBBmZlaXA8LMzOpyQJiZWV0OCDMzq8sBYWZmdTkgzMysrq52N+BkLFmyJFavXt3uZpiZzSgPP/zwzogYaFVvRgfE6tWrGRwcbHczzMxmFEk/m049n2IyM7O6HBBmZlaXA8LMzOpyQJiZWV0OCDMzqyvXgJC0QNIdkn4kabOkN0haJOk+Sc+k6cJUV5JulLRF0mOSLsyzbWZm1lzeRxCfBr4ZEa8CXgdsBq4HNkXEGmBTWga4DFiTXhuAm3Jum5mZNZFbQEiaB7wZuAUgIkYiYg+wDtiYqm0Erkjz64DbIvMAsEDS8jza9tBzu/jEt55mZKySx+bNzM4IeR5BnAsMAZ+X9ENJn5U0B1gWES8CpOnSVH8F8ELN+7emslPuBz/bzX/79hb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9p8lO7/wgdRQPUf/xqt8E3iPpMbIf4Adq1t0MPCbpBxHxezXlXwfeQDZSbgB/FBEvpYCpZy5wp6Q+sr/eP1inzneBT0hSzV/wTwN/T9bP8Z6IOCLps9Pcr6mO2hdJf0L2tMES2Siz1wE/a/L+j0tak9q/Ke07wC8DfzuNz7czmC9zNcuZpE+Tdfj+Xbq/4O6IuKPF29pGUi9ZgL0pJh9taQXkU0xm+ftzYHa7G3EczgaudziYjyDMzKwuH0GYmVldDggzM6vLAWFmZnU5IMzMrC4HhJmZ1eWAMDOzuv4/w87bwpgYMqwAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4wLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvqOYd8AAAIABJREFUeJzt3Xl8VOXZ//HPTQTCKg/IjpBIQVmEIEFAtCqRRQS0VtyiFR9/xa0VWzcEFR8FxR9WqsWl1AXUVNyK0IrFDQSxUoJsCgpGAkYRA09ZYmQJuZ4/Zogkk5CEzMyZOfN9v168krnmZM7FYfjmzH2fxZkZIiIS/2p53YCIiISHAl1ExCcU6CIiPqFAFxHxCQW6iIhPKNBFRHxCgS4i4hMKdBERn1Cgi4j4xDHRXNlxxx1nKSkp0VyliEjcW7FixXYza17ZclEN9JSUFLKzs6O5ShGRuOec21yV5TTkIiLiEwp0ERGfUKCLiPhEVMfQy3PgwAHy8vLYu3ev160IkJycTLt27ahdu7bXrYhINXke6Hl5eTRq1IiUlBScc163k9DMjB07dpCXl0dqaqrX7YhINXk+5LJ3716aNWumMI8BzjmaNWumT0si4ZKVBSkpUKtW4GtWVkRX5/keOqAwjyH6txAJk6wsGDMGCgsDjzdvDjwGyMyMyCo930MXEfGlCRN+CvNDCgsD9QhRoBMYxz///PPp1KkTHTt2ZOzYsezfv7/cZb/99lsuuuiiSl9z2LBh7Ny586j6uffee3n44YcrXa5hw4ZHfH7nzp088cQTR9WDiNTQli3Vq4dB/AV6mMekzIwLL7yQCy64gI0bN7JhwwYKCgqYUM5v0aKiItq0acNrr71W6evOnz+fJk2a1Ki3mlKgi3ioffvq1cMgvgL90JjU5s1g9tOYVA1C/f333yc5OZmrr74agKSkJKZNm8azzz5LYWEhM2fOZNSoUYwYMYLBgweTm5tL9+7dASgsLOTiiy+mR48eXHLJJfTt27fk0gYpKSls376d3NxcunTpwq9//Wu6devG4MGD+fHHHwH4y1/+Qp8+fejZsye//OUvKSz78ayMTZs20b9/f/r06cPdd99dUi8oKCAjI4NTTjmFk08+mblz5wIwbtw4cnJySEtL47bbbqtwORGJgMmToX790rX69QP1SDGzqP3p3bu3lbVu3bqQWoU6dDALRHnpPx06VP01ynj00Uft5ptvDqmnpaXZ6tWr7bnnnrO2bdvajh07zMxs06ZN1q1bNzMzmzp1qo0ZM8bMzNauXWtJSUm2fPnyYKsdLD8/3zZt2mRJSUm2cuVKMzMbNWqUvfDCC2Zmtn379pL1TZgwwR577DEzM5s4caJNnTo1pKcRI0bYrFmzzMxs+vTp1qBBAzMzO3DggO3atcvMzPLz861jx45WXFxcqtcjLVdWtf5NRKRiL74YyCfnAl9ffPGoXgbItipkbEwc5VJlERiTMrNyj+w4vD5o0CCaNm0assyHH37I2LFjAejevTs9evQodx2pqamkpaUB0Lt3b3JzcwH49NNPueuuu9i5cycFBQUMGTLkiL0uXbqU119/HYArr7ySO+64o6TX8ePHs3jxYmrVqsU333zDtm3byv07lbdcq1atjrheETlKmZkRO6KlPPE15BKBMalu3bqFXAFy9+7dfP3113Ts2BGABg0alPuzgV+clatbt27J90lJSRQVFQEwevRopk+fztq1a5k4cWKVjv8u75dPVlYW+fn5rFixglWrVtGyZctyX6uqy4l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gteAi1d42CvQynHMjgW/MbHWZp9oCXx/2OC9YS1T/DbwV/F7bJkDboQLOuRSgF7AMaGlmWyEQ+kAL7zrz1B8J7DgWBx83A3YettNU7fdPXNwkOtycc+8Crcp5agIwHhhc3o+VU/PdIUJH2jZmNje4zAQCH6ezDv1YOcv7bttUgbZDOZxzDYHXgZvNbHdgRzSxOeeGA9+b2Qrn3FmHyuUsWq33T0IGupmdU17dOXcykAqsDr7p2gGfOOdOJfDb8vjDFm8HfBvhVqOuom1ziHPuKmA4kGE/HfOaENumCrQdynDO1SYQ5llm9rdgeZtzrrWZbQ0OW37vXYeeGQCMdM4NA5KBxgT22Js4544J7qVX+/2jIZfDmNlaM2thZilmlkLgP+gpZvYdMA/4VfBol37ArkMfGxOFc24ocAcw0swKD3tqHnCpc66ucy6VwMTxv73o0WPLgU7BIxXqEJgonudxT54Jjgk/A6w3s0cOe2oecFXw+6uAudHuzWtmdqeZtQvmzKXA+2aWCSwELgouVu1tk5B76EdpPjCMwIRfIXC1t+14YjpQF3gn+AnmYzO7zsw+c869AqwjMBRzo5kd9LBPT5hZkXPuN8ACIAmsg00KAAAAZ0lEQVR41sw+87gtLw0ArgTWOudWBWvjgSnAK865awgcSTbKo/5i0R3AbOfcJGAlgV+IVaYzRUVEfEJDLiIiPqFAFxHxCQW6iIhPKNBFRHxCgS4i4hMKdBERn1Cgi4j4hAJdRMQn/g8Pvr1YHnkeMgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#  Fitting linear regression 拟合线性回归\n",
    "costs, W, b = model(train_X, train_y, lambd=0.0)\n",
    "# plot the cost\n",
    "plt.plot(np.squeeze(costs))\n",
    "plt.ylabel('cost')\n",
    "plt.xlabel('iterations (per tens)')\n",
    "plt.show()\n",
    "\n",
    "plt.plot(train_X, train_y, 'ro', label='Original data')\n",
    "plt.plot(train_X, W * train_X + b, label='Fitted line')\n",
    "plt.legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def plot_learning_curve(X, y, Xval, yval, l):\n",
    "    \"\"\"画出学习曲线，即交叉验证误差和训练误差随样本数量的变化的变化\"\"\"\n",
    "    pass\n",
    "    # xx = range(1, len(X) + 1)  # at least has one example \n",
    "    # training_cost, cv_cost = [], []\n",
    "    # training_cost = model(X, y, l)\n",
    "    # cv_cost_i = costReg(res, Xval, yval, 0)\n",
    "    # cv_cost.append(cv_cost_i)\n",
    "    #     \n",
    "    # plt.figure(figsize=(8,5))\n",
    "    # plt.plot(xx, training_cost, label='training cost')  \n",
    "    # plt.plot(xx, cv_cost, label='cv cost') \n",
    "    # plt.legend()\n",
    "    # plt.xlabel('Number of training examples')\n",
    "    # plt.ylabel('Error')\n",
    "    # plt.title('Learning curve for linear regression')\n",
    "    # plt.grid(True)"
   ]
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 0
}